<div id="notify_in_ildds" class="easyui-layout tab_a" fit="true">
    <div data-options="region:'center',border:false">
        <table id="notify_in_list"></table>
        <div id="notifyinboxtoolbar" style="padding:5px;height:auto">
            <div>
                <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="notify_read()">标记为已读</a>
                <label style=" float:right;" >
                    	<input id="notify_in_search_key" class="notify_in_search_form textbox" style="width:200px;" type="text">
                    	<a href="#" class="easyui-linkbutton notify_in_search_form" plain="true"  iconCls="icon-search" onclick="advanced_search('notify_in','notify_in_search_key')">搜索</a>
                    <a id="notify_in_advancedSearch" href="javascript:void(0)" class="easyui-linkbutton" plain="true" onclick="advanced_search('notify_in','高级')">高级</a>
                    
                </label>
            </div>
        </div>
	</div>
</div>
<script>

//收件箱数据构造方法，包括列表属性设置，字段设置，双击设置
$('#notify_in_list').datagrid({
    url:'<?php echo base_url('notify/inbox_data');?>',
	singleSelect:true,
	selectOnCheck:false,
	pagination:true,
	pageSize:30,
	pageList:[30,50,100],
	fit:true,
	fitColumns:true,
	border:false,
	sortName:'notify_id',
	sortOrder:'desc',
	toolbar:'#notifyinboxtoolbar',
    columns:[[
		{field:'id',checkbox:true},
		{field:'dept_name',title:'发布部门',width:30,align:'center'},
		{field:'sender',title:'发布人',width:16,align:'center'},
		{field:'type_id',title:'类型',width:16,align:'center',
			formatter: function(value,row,index){
				if(value == 1){
					return "通知";
				}else{
					return "公告";
				}
			}
		},
		{field:'title',title:'标题',width:180},
		{field:'to_name',title:'发布范围',width:100,align:'center',
			formatter: function(value,row,index){
				return "<div title='"+value+"'>"+subStringCh(value,40,true)+'</div>';
			}
		},
        {field:'sendertime',title:'发布时间',width:40,align:'center',sortable:'true',
			formatter: function(value,row,index){
				//return getLocalTime(value);
				return value;
			}
		}
    ]],
	onDblClickRow:function(index,data){

			var title = (strlen(data.title) >10)?SetString(data.title,10)+'..':data.title;//如果标题超过10个字符，则截取10个字符加..
			var ns_id = 'ns_'+data.id; //拼接面板ID
			var ns_obj = $('#main-tab').find("#"+ns_id);//获取面板ID对象对象
			//alert(es_obj.length);
			
			if (ns_obj.length>0){ //如果存在
				var tab_index = ns_obj.parent().index();//检查该对象的父元素在其父元素中的索引
				$('#main-tab').tabs('select', tab_index); //选择该索引对应的面板
			} else {
				/**添加一个tab标签**/
				$("#main-tab").tabs('add',{
					id: ns_id,
					title: '通知公告：'+title,
					href: '<?php echo base_url();?>notify/contentbox/'+data.id,
					tabWidth:'180',
					selected: true,
					closable:true,
					onLoad:function(){
						//为面板添加详细标题属性 
						var item1 = $('.tabs-selected').find("span:first");
						$('#main-tab').find(item1).attr("title",data.title);
						
						//刷新收件箱列表
						//$('#notify_in_list').datagrid('reload');					
					}
				});
			}
		//}
	},
	onLoadSuccess:function(){
        var pager = $(this).datagrid('getPager');
        pager.pagination({
            displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'
        });
    }

});

//"设为已读"函数
function notify_read(){
	var getobj = $('#notify_in_list').datagrid("getChecked");
	var getid = [];
		$.each(getobj, function(index, item){
			getid.push(item.id);
		}); 
	if(getid.length == 0){
		$.messager.alert('错误','要设为已读，请选取要操作的行','error');
	}else{            
		$.post("<?php echo base_url('notify/notify_setread');?>",{getid:getid},function(result){
			if(result.success){
				$('#notify_in_list').datagrid('reload');
			}else{
				$.messager.alert('错误',result.errorMsg,'error');
			}
		},'json');
	}
}
</script>